package com.hm_.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.hm.model.User;

@RequestMapping("user")
@Controller
public class GetUserController {

	@RequestMapping("guser")
	public @ResponseBody Object getUser(@RequestParam("aaa") User user) {
		if (1 == 1)
			throw new NullPointerException("数据库不见了");
		return user;
	}

	@RequestMapping("mv")
	public ModelAndView hellmv() {
		Map<String, Object> map = new HashMap<>();
		map.put("banner", "我是一个有理想的咸鱼");
		ModelAndView modelAndView = new ModelAndView("h",map);
		return modelAndView;
	}
	@RequestMapping("print")
	public void aaa(PrintWriter pw,HttpServletResponse reponse) {
		reponse.setContentType("text/html;charset=utf-8");
//		pw.println("<h1>这里是打印输出流</h1>");
		try {
			reponse.getWriter().println("<h1>这里是打印输出流</h1>");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
